package com.treasure.mall.biz.repository.product;

import com.treasure.mall.biz.base.JpaSearchableRepository;
import com.treasure.mall.biz.entity.product.CategoryPO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author wm
 */
@Repository
public interface CategoryRepository extends JpaSearchableRepository<CategoryPO, Long> {
    @Query("select a from CategoryPO a where a.depth<=2 order by a.sortNo")
    List<CategoryPO> getListLevelTop2();

    @Query("select a from CategoryPO a where a.parentCatId=?1 order by a.sortNo")
    List<CategoryPO> getList(Long parentCatId);

    @Query("select a from CategoryPO a where a.recommendFlag=1 and a.statusCode=1 order by a.sortNo")
    List<CategoryPO> getRecommendList();

    @Query("select a from CategoryPO a where a.depth<=2 and a.statusCode=1 order by a.sortNo")
    List<CategoryPO> getActiveListLevelTop2();
}